package com.itany.shop.vo;

import com.itany.shop.entity.Item;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Author:shixiaojun@itany.com
 * Date:2022/4/15 14:20
 * Version:1.0-SNAPSHOT
 * Description: 购物车VO对象
 */
public class Cart implements Serializable {

    // 购物车中的明细
    private List<Item> items = new ArrayList<>();
    // 购物车总价,总价需要进行运算,其默认值为null
    // 而null无法进行运算
    // 因此,必须给定一个默认值0
    private Double price = 0.0;

    public void addItem(Item item){
        items.add(item);
    }

    public void removeItem(Item item){
        items.remove(item);
    }

    public List<Item> getItems() {
        return items;
    }

    public void setItems(List<Item> items) {
        this.items = items;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }
}
